import request from '@/utils/request'

export function getAccount(query) {
  return request({
    url: '/api/account/',
    method: 'get',
    params: query
  })
}

export function createAccount(data) {
  return request({
    url: '/api/account/',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}

export function updateAccount(id, data) {
  return request({
    url: '/api/account/' + id + '/',
    method: 'patch',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}

// 更新用户的进出校权限
export function updateSchoolPerm(data) {
  return request({
    url: '/api/account/update_school_perms/',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}

// 上传打卡白名单
export function uploadWhiteList(form) {
  return request({
    url: '/api/account/upload_white_list/',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: form
  })
}

// 上传打卡黑名单
export function uploadBlackList(form) {
  return request({
    url: '/api/account/upload_black_list/',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: form
  })
}

// 上传通知白名单
export function uploadNotifyExcel(form) {
  return request({
    url: '/api/account/upload_notify_list/',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: form
  })
}

export function deleteAccount(id) {
  return request({
    url: '/api/account/' + id + '/',
    method: 'delete'
  })
}

// 获取用户有权限查看的人员类型
export function getPersonType(query) {
  return request({
    url: '/api/account/get_person_type/',
    method: 'get',
    params: query
  })
}

// 获取用户的打卡历史
export function getRecordHistory(query) {
  return request({
    url: '/api/record/record_history/',
    method: 'get',
    params: query
  })
}

// 获取打卡详情
export function getRecordDetail(query) {
  return request({
    url: '/api/record/get_record_detail/',
    method: 'get',
    params: query
  })
}

// 同步数据中心新增的用户
export function addUser() {
  return request({
    url: '/api/account/update_user/',
    method: 'post'
  })
}

// 同步数据中心和系统中在职在读的人员信息
export function updateUserAtSchool() {
  return request({
    url: '/api/account/update_or_add_user/',
    method: 'post'
  })
}

// 获取打卡人员类型
export function getCardType(query) {
  return request({
    url: '/api/account/get_card_type/',
    method: 'get',
    params: query
  })
}

// 取消所有人的查看通知权限
export function cancelViewNotify() {
  return request({
    url: '/api/account/cancel_all_notify/',
    method: 'post'
  })
}

// 开通用户的打卡权限
export function openCardPerm(id, data) {
  return request({
    url: '/api/account/' + id + '/open_card_perm/',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}

// 关闭用户的打卡权限
export function closeCardPerm(id, data) {
  return request({
    url: '/api/account/' + id + '/close_card_perm/',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}
